# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html
import re
import scrapy
from Blog_Category.items import BlogCategoryItem
# import logging
# import inspect


class BlogCategoryPipeline(object):
    def process_item(self, item, spider):
        # frame = inspect.currentframe()
        # logging.log(logging.DEBUG, "### FUNC {0} line {1}###".format(__name__, frame.f_lineno))
        # logging.log(logging.DEBUG, "### item {0} ###".format(item))
        category = item.get('category', None)
        # logging.log(logging.DEBUG, "### category {0} ###".format(category.encode('utf-8')))
        if category and re.search(u'^Qt', category):
            raise scrapy.exceptions.DropItem("Drop item startwiths 'Qt' : %s" % item)
        return item


